builtin: add :ne, inequality over two evaluated constants - #92
builtin: add :ne, inequality over two evaluated constants#92brian-slashguard wants to merge 1 commit into
Conversation
Mangle has :lt/:le/:gt/:ge but no not-equals, so every inequality must be written as negation over a domain the program derives first. That is a recurring authoring and review cost for a common construct. Adds :ne at the four registration points :lt uses — symbol, arg modes, decision case, and relation type. The relation type is the non-obvious one: without it the predicate parses and reaches evaluation, then fails type inference with 'cannot find assignment that works for premise :ne(A,B)', which reads like a broken implementation. Verified: differs(A,B) :- colour(A), colour(B), :ne(A,B) over three colours yields the six ordered pairs of distinct values.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hey there! First, an administrative remark: this project lives on codeberg now. I can review it here, but I'd prefer to not depend on github. Now, about the PR itself:
In fact, built-in predicates are specific to types - there should be a ":float:lt" etc for floats, but that was missing which I will add now. |
Mangle has
:lt/:le/:gt/:gebut no not-equals, so every inequality must be written as negation over a domain the program derives first.This adds
:neat the same four registration points:ltuses: symbol declaration, arg modes, the decision case, and the relation type.The relation type is the non-obvious one — without it the predicate parses and reaches evaluation, then fails type inference with
cannot find assignment that works for premise :ne(A,B), which reads like a broken implementation rather than a missing registration.Verified:
differs(A,B) :- colour(A), colour(B), :ne(A,B).over three colours yields the six ordered pairs of distinct values.go build ./...is clean.Happy to adjust naming or the type bound if you'd prefer something narrower than
AnyBound.